import request from '@utils/request'
// 请求icon
const getIcon = () => request.get('http://localhost:3000/api/phone/getIconfont')
// 请求物品数据

const getHomegood = (type = 'sales', data) => request.get('http://localhost:3000/api/phone/salesThings?' + 'page=' + data.page + '&' + 'size=' + data.size)
// 列表
const getList = () => request.get('/goods')
// 分类

const cateList = (query, size = 4, page = 1) => request.get(`http://localhost:3000/api/phone/cateList?query=${query}&size=${size}&page=${page}`)

const getListSort = (order = 'sales', cid = 0, page = 1) => request.get(`/goods?category_id=${cid}&page=${page}&${order}=1`)
// 获取详情
const getDetail = (id) => request.get(`http://localhost:3000/api/phone/getDetail?id=${id}`)
// 登录
const login = (userinfo) => request.post('http://localhost:3000/api/phone/login', userinfo)
// 注册
const register = (data) => request.post('http://localhost:3000/api/users/register', data)
// 添加地址Addaddress
const addAddress = (data) => request.post('http://localhost:3000/api/phone/Addaddress', data)
// 查询地址
const getAddress = () => request.post('http://localhost:3000/api/phone/getAddress')
// 查询单个地址
const getOneAddress = (id) => request.get(`http://localhost:3000/api/phone/GetOneaddress?id=${id}`)
// 删除地址
const delOneAddress = (id) => request.post('http://localhost:3000/api/phone/Deladdress', {
  params: {
    id
  }
})
// 更新地址
const updateAddress = (data) => request.post('http://localhost:3000/api/phone/Updateaddress', data)
// 更新订单
const updateOrder = (data) => request.post('http://localhost:3000/api/phone/UpdataOrder', data)
// 搜索
const searchData = (data) => request.get(`http://localhost:3000/api/phone/SearChData?query=${data}`)
// 个人信息
const detailInfo = () => request.post('http://localhost:3000/api/phone/detailInfo')
// 更新个人信息
const updateInfo = (data) => request.post('http://localhost:3000/api/phone/updateInfo', data)
// 更新头像
// const updateImg = (data) => request.post('http://localhost:3000/api/phone/updateImg', data, {
//   headers: { 'Content-Type': 'multipart/form-data' }
// })
// 个人订单
const getOrderList = () => request.post('http://localhost:3000/api/phone/getOrderList')
// 个人订单详情
const getOneOrderDeatil = (data) => request.get(`http://localhost:3000/api/phone/getOneOrderDeatil?id=${data}`)
// 历史记录
const productHistory = (data) => request.post('http://localhost:3000/api/phone/productHistory', data)
// 获取历史
const getHistory = () => request.get('http://localhost:3000/api/phone/getHistory')
// 删除历史
const delHistory = () => request.post('http://localhost:3000/api/phone/delHistory')


export {
  getHomegood,
  getList,
  getListSort,
  getDetail,
  login,
  register,
  getIcon,
  addAddress,
  getAddress,
  getOneAddress,
  delOneAddress,
  updateAddress,
  updateOrder,
  searchData,
  detailInfo,
  updateInfo,
  getOrderList,
  getOneOrderDeatil,
  cateList,
  productHistory,
  getHistory,
  delHistory
  // updateImg
}
